<template>
  <a-card :bordered="false">
    <div style="display: flex; justify-content: space-between">
      <!-- 操作按钮区域 -->
      <div class="table-operator">
        <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('订单表')">导出</a-button>
      <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
        <a-dropdown v-if="selectedRowKeys.length > 0">
          <a-menu slot="overlay">
            <a-menu-item key="1" @click="batchDel"><a-icon type="delete" />删除</a-menu-item>
          </a-menu>
          <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
        </a-dropdown>
      </div>
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-form-item label="城市服务商" style="margin-right: 10px" v-has="'xhdjDataReview:select'">
            <serveSelect @selectClick="selectClick" :value="queryParam.agencyCode"></serveSelect>
          </a-form-item>
          <a-form-item label="技师编号" style="margin-right: 10px">
            <a-input placeholder="请输入用户编号" v-model="queryParam.coachId" @pressEnter="searchQuery"></a-input>
          </a-form-item>
          <a-form-item label="技师" style="margin-right: 10px">
            <a-input placeholder="请输入技师" v-model="queryParam.coachName" @pressEnter="searchQuery"></a-input>
          </a-form-item>
          <a-form-item label="开始时间" style="margin-right: 10px">
            <a-date-picker v-model="queryParam.startTime" @change="startChange" :valueFormat="'YYYY-MM-DD'" />
          </a-form-item>
          <a-form-item label="结束时间" style="margin-right: 10px">
            <a-date-picker
              v-model="queryParam.endTime"
              @change="endChange"
              :valueFormat="'YYYY-MM-DD'"
              :disabled-date="disabledDate"
            />
          </a-form-item>
          <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
            <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
          </span>
        </a-form>
      </div>
    </div>
    <!-- table区域-begin -->
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      class="j-table-force-nowrap"
      @change="handleTableChange"
    >
      <template slot="selfImg" slot-scope="text, record">
        <div class="anty-img-wrap">
          <j-image-upload v-if="record.selfImg" text="上传" disabled v-model="record.selfImg"></j-image-upload>
        </div>
      </template>

      <template slot="workImg" slot-scope="text, record">
        <div class="anty-img-wrap">
          <j-image-upload v-if="record.workImg" text="上传" disabled v-model="record.workImg"></j-image-upload>
        </div>
      </template>
      <template slot="individualResume" slot-scope="text, record">
        <a-tooltip placement="topLeft" :title="text">
          <div style="max-width: 10em; line-height: 1.5; overflow: hidden; text-overflow: ellipsis;">
            {{record.individualResume}}
          </div>
        </a-tooltip>
      </template>
      <template slot="video" slot-scope="text, record">
        <div class="anty-img-wrap" style="height: 80px" v-if="record.video">
          <video controls style="width: 80px; height: 80px">
            <source :src="record.video" type="video/mp4" />
          </video>
        </div>
      </template>

      <span slot="action" slot-scope="text, record">
        <div v-if="record.status === 0">
          <a-popconfirm title="确定通过吗?" @confirm="() => handlePass(record.id)">
            <a>通过</a>
          </a-popconfirm>
          <a-divider type="vertical" />
          <a-popconfirm title="确定驳回吗?" @confirm="() => handleReject(record.id)">
            <a>驳回</a>
          </a-popconfirm>
        </div>
      </span>
    </a-table>
    <!-- table区域-end -->
    <!-- 表单区域 -->
    <!-- <xhdjOrderInfo-modal ref="modalForm" @ok="modalFormOk"></xhdjOrderInfo-modal> -->
    <!-- <XhdjOrderInfoDialog ref="dialogForm"></XhdjOrderInfoDialog> -->
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
// import XhdjOrderInfoModal from './modules/XhdjOrderInfoModal'
import { getAction, getFileAccessHttpUrl } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import serveSelect from '@/components/serveSelect.vue'

// import XhdjOrderInfoDialog from './modules/XhdjOrderInfoDialog.vue'
export default {
  name: 'xhdjDataReviewList',
  mixins: [JeecgListMixin],
  components: {
    serveSelect
  },
  data () {
    return {
      description: '订单表管理页面',
      options: [
        { label: '车费', value: '0' },
        { label: '服务', value: '1' }
      ],
      statuses: {
        0: '待审核',
        1: '已审核',
        2: '驳回'
      },
      types: {
        0: '简介',
        1: '生活照',
        2: '手机号',
        3: '形象照',
        4: '个人视频'
      },
      // 表头
      columns: [
        { title: '技师编号', align: 'center', dataIndex: 'coachId' },
        {
          title: '技师昵称',
          align: 'center',
          dataIndex: 'coachName'
        },
        {
          title: '审核类型',
          align: 'center',
          dataIndex: 'type',
          customRender: (text, record) => {
            return this.types[record.type]
          }
        },
        {
          title: '接单电话',
          align: 'center',
          dataIndex: 'mobile'
        },
        {
          width: 380,
          title: '生活照',
          align: 'center',
          dataIndex: 'selfImg',
          scopedSlots: { customRender: 'selfImg' }
        },
        {
          title: '技师简介',
          align: 'center',
          dataIndex: 'individualResume',
          scopedSlots: { customRender: 'individualResume' }

        },
        {
          width: 150,
          title: '形象照',
          align: 'center',
          dataIndex: 'workImg',
          scopedSlots: { customRender: 'workImg' }
        },
        {
          width: 150,
          title: '个人视频',
          align: 'center',
          dataIndex: 'video',
          scopedSlots: { customRender: 'video' }
        },
        {
          title: '审核状态',
          align: 'center',
          dataIndex: 'status',
          customRender: (text, record) => {
            return this.statuses[record.status]
          }
        },
        {
          title: '创建日期',
          align: 'center',
          dataIndex: 'createTime'
        },
        {
          title: '更新时间',
          align: 'center',
          dataIndex: 'updateTime'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          width: 150,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/coach/xhdjCoachInfoAudit/list',
        delete: '/xhdjOrderInfo/delete',
        passUrl: '/coach/xhdjCoachInfoAudit/pass',
        reject: '/coach/xhdjCoachInfoAudit/refused'
      }
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    // 通过
    handlePass (id) {
      getAction(this.url.passUrl, { id }).then(res => {
        if (res.code == 200) {
          this.$message.success(res.message)
          this.loadData()
        } else {
          this.$message.console.error(res.message)
        }
      })
    },
    startChange (value) {
      if (value) {
        this.queryParam.startTime = value + ' 00:00:00'
      } else {
        this.queryParam.startTime = value
      }
    },
    endChange (value) {
      if (value) {
        this.queryParam.endTime = value + ' 23:59:59'
      } else {
        this.queryParam.endTime = value
      }
    },
    selectClick (value) {
      this.queryParam.agencyCode = value
      this.searchQuery()
    },
    disabledDate (time) {
      return new Date(time).getTime() < new Date(this.queryParam.startTime).getTime()
    },
    getAvatarView: function (avatar) {
      return getFileAccessHttpUrl(avatar)
    },
    handleReject (id) {
      getAction(this.url.reject, { id }).then(res => {
        if (res.code == 200) {
          this.$message.success(res.message)
          this.loadData()
        } else {
          this.$message.console.error(res.message)
        }
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
.ant-row {
  display: flex;
  justify-content: flex-end;
}
.ant-col {
  display: flex;
  justify-content: flex-end;
}
.ant-form {
  display: flex;
}
.anty-img-wrap /deep/ .ant-upload-picture-card-wrapper {
  height: 150px;
  display: block !important;
}
</style>
